﻿using CommonTool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tool;
using System.Drawing;
using System.Diagnostics;
using Motions;
using AutoMachine;
using Station;

namespace Motions
{
    /// <summary>
    /// 上下料弹夹
    /// </summary>
     class UpAndDownLoad : StationBase
    {
        #region CT计算
        private Stopwatch CTtime = new Stopwatch();

        public string CT = "";

        #endregion

        #region 流程步

        private int AutoStep = 0;

        #endregion

        public UpAndDownLoad(string name) : base(name) { }

        /// <summary>
        /// 停止流程
        /// </summary>
        public override void StopWork()
        {
            this.AutoStep = 0;
            SystemMgr.GetInstance().WriteSysInt(SysInt.UpAndDownLoadStep, 0);
        }

        /// <summary>
        /// 急停流程
        /// </summary>
        public override void EmgWork()
        {
            this.AutoStep = 0;
        }

        /// <summary>
        /// 自动流程
        /// </summary>

        public override void AutoWork()
        {
            WriteSysInt(SysInt.UpAndDownLoadStep, AutoStep);
            WaitRun();
            switch (AutoStep)
            {
                case 0:
                    if (GetSysBit(SysBit.左工位屏蔽) == true)
                    {
                        Thread.Sleep(5);
                        break;
                    }
                    AutoStep = 10;
                    break;
                case 10:
                    //if (GetSysBit(SysBit.UpAndDownLoadRunning))
                    //{
                    //    if (GetSysBit(SysBit.MagSplitRunOK))
                    //    {
                    //        WriteSysBit(SysBit.MagSplitRunOK, false);
                    //        WriteSysBit(SysBit.UpAndDownLoadRunning,false);
                    //        AutoStep = 100;
                    //    }
                    //    else if(GetSysBit(SysBit.OKMagMergeRunOK))
                    //    {
                    //        WriteSysBit(SysBit.OKMagMergeRunOK, false);
                    //        WriteSysBit(SysBit.UpAndDownLoadRunning, false);
                    //        AutoStep = 200;
                    //    }

                        
                    //}
                  
                   
                    break;
                case 100:

                    if (GetSysBit(SysBit.UpAndDownLoadDown2HaveUnit))
                    {
                        AbsMove("上下料上料搬运2取料位");
                        WaitAbs("上下料上料搬运2取料位");
                        QG_夹爪升降气缸1动点();
                        QG_夹爪气缸1动点();
                        QG_夹爪升降气缸1原点();
                        AbsMove("上下料上料搬运拆分位");
                        WaitAbs("上下料上料搬运2拆分位");
                        QG_夹爪升降气缸1动点();
                        QG_夹爪气缸1原点();
                        QG_夹爪升降气缸1原点();
                        WriteSysBit(SysBit.UpAndDownLoadDown2HaveUnit, false);
                    }
                    AutoStep = 30;
                    break;
                case 30:
                    Thread.Sleep(4000);
                    //MotionMgr.GetInstance().AbsMove("左载具R待机位");
                    //MotionMgr.GetInstance().AbsMove("左直线X待机位");
                    //MotionMgr.GetInstance().AbsMove("左相机Y待机位");
                    //MotionMgr.GetInstance().AbsMove("左载具Z待机位");

                    //MotionMgr.GetInstance().WaitAbs("左载具R待机位");
                    //MotionMgr.GetInstance().WaitAbs("左直线X待机位");
                    //MotionMgr.GetInstance().WaitAbs("左相机Y待机位");
                    //MotionMgr.GetInstance().WaitAbs("左载具Z待机位");
                    AutoStep = 40;
                    break;
                case 40:

                    //WriteSysBit(SysBit.左相机发送至左取料请求放料信号, true);
                    AutoStep = 50;
                    break;
                case 50:
                    Thread.Sleep(5000);
                    //WriteSysBit(SysBit.左相机发送至左取料请求放料信号, false);
                    //SystemMgr.GetInstance().WaitSysBit((int)SystemMgr.SysBit.左取料发送至左相机请求吸真空信号, true);
                    //SystemMgr.GetInstance().WriteSysBit((int)SystemMgr.SysBit.左取料发送至左相机请求吸真空信号, false);
                    //SystemMgr.GetInstance().WaitSysBit((int)SystemMgr.SysBit.左取料发送至左相机请求吸真空信号, false);
                    AutoStep = 0;
                    break;
                case 60:
                    //QG_左载具夹紧气缸1去动点();
                    //QG_左载具夹紧气缸2去动点();
                    AutoStep = 70;
                    break;
                case 70:
                    //ZK_左载具真空吸1真空开();
                    //ZK_左载具真空吸2真空开();
                    AutoStep = 80;
                    break;
                case 80:
                    //WriteSysBit(SysBit.左相机发送至左取料允许离开信号, true);
                    AutoStep = 90;
                    break;
                case 90:
                    //WaitSysBit(SysBit.左取料发送至左相机放料完成信号, true);
                    //WriteSysBit(SysBit.左取料发送至左相机放料完成信号, false);
                    //WaitSysBit(SysBit.左取料发送至左相机放料完成信号, false);
                    AutoStep = 100;
                    break;
                case 1000:
                    AbsMove("左直线X拍照待机位");
                    WaitAbs("左直线X拍照待机位");
                    //CT记时                   
                    //开始1
                    AbsMove("左直线X拍照1位");
                    AbsMove("左相机Y拍照1位");
                    AbsMove("左载具R拍照1位");
                    AbsMove("左载具Z拍照1位");

                    WaitAbs("左直线X拍照1位");
                    WaitAbs("左相机Y拍照1位");
                    WaitAbs("左载具R拍照1位");
                    WaitAbs("左载具Z拍照1位");

                    CTtime.Reset();
                    CTtime.Start();

                    Thread.Sleep(100);
                    WriteOut("左相机翻转信号", true);
                    Thread.Sleep(100);

                    LogView.GetInstance().ShowLog(LogView.LogType.Oper, "左相机触发拍照1");
                    Thread.Sleep(100);
                    WriteOut("左相机帧信号", true);

                    //到达2
                    AbsMove("左直线X拍照2位");
                    AbsMove("左相机Y拍照2位");
                    AbsMove("左载具R拍照2位");
                    AbsMove("左载具Z拍照2位");

                    WaitAbs("左直线X拍照2位");
                    WaitAbs("左相机Y拍照2位");
                    WaitAbs(" 左载具R拍照2位");
                    WaitAbs("左载具Z拍照2位");

                    WaitCamerL();
                    GlobalVar.CamerL_Over = false;

                    Thread.Sleep(100);
                    MotionMgr.GetInstance().WriteOut("左相机帧信号", false);
                    Thread.Sleep(100);
                    MotionMgr.GetInstance().WriteOut("左相机翻转信号", false);


                    if (GlobalVar.VisRepate == true)
                    {
                        AutoStep = 100;
                    }
                    else
                    {
                        AutoStep = 110;
                    }

                    break;

                case 110:
                    //开始3
                    AbsMove("左直线X拍照3位");
                    AbsMove("左相机Y拍照3位");
                    AbsMove("左载具R拍照3位");
                    AbsMove("左载具Z拍照3位");

                    WaitAbs("左直线X拍照3位");
                    WaitAbs("左相机Y拍照3位");
                    WaitAbs("左载具R拍照3位");
                    WaitAbs("左载具Z拍照3位");

                    Thread.Sleep(100);

                    ShowLog("左相机触发拍照2");
                    Thread.Sleep(100);
                    WriteOut("左相机帧信号", true);


                    //到达4
                    AbsMove("左直线X拍照4位");
                    AbsMove("左相机Y拍照4位");
                    AbsMove("左载具R拍照4位");
                    AbsMove("左载具Z拍照4位");

                    WaitAbs("左直线X拍照4位");
                    WaitAbs("左相机Y拍照4位");
                    WaitAbs("左载具R拍照4位");
                    WaitAbs("左载具Z拍照4位");

                    WaitCamerL();
                    GlobalVar.CamerL_Over = false;

                    Thread.Sleep(100);
                    MotionMgr.GetInstance().WriteOut("左相机帧信号", false);

                    if (GlobalVar.VisRepate == true)
                    {
                        AutoStep = 110;
                    }
                    else
                    {
                        AutoStep = 120;
                    }

                    break;
                case 190:
                    //记时结束
                    TimeSpan ts = CTtime.Elapsed;
                    CT = ts.TotalSeconds.ToString("f2");
                    CTtime.Stop();
                    ShowLog("CT时间：" + CT.ToString());

                    AutoStep = 200;
                    break;
                case 200:
                    //WaitSysBit(SysBit.左下料发送至左相机请求放料信号, true);
                    //WriteSysBit(SysBit.左下料发送至左相机请求放料信号, false);
                    //WaitSysBit(SysBit.左下料发送至左相机请求放料信号, false);
                    AutoStep = 210;
                    break;
                case 210:
                    AbsMove("左直线X下料位");
                    AbsMove("左载具R下料位");
                    AbsMove("左载具Z下料位");

                    WaitAbs("左直线X下料位");
                    WaitAbs("左载具R下料位");
                    WaitAbs("左载具Z下料位");
                    AutoStep = 220;
                    break;
                case 220:
                    //WriteSysBit(SysBit.左相机发送至左下料请求取料信号, true);
                    AutoStep = 230;
                    break;
                case 230:
                    //WaitSysBit(SysBit.左下料发送至左相机请求破真空信号, true);
                    //WriteSysBit(SysBit.左下料发送至左相机请求破真空信号, false);
                    //WaitSysBit(SysBit.左下料发送至左相机请求破真空信号, false);
                    AutoStep = 240;
                    break;
                case 240:
                    //QG_左载具夹紧气缸1回原点();
                    //QG_左载具夹紧气缸2回原点();
                    //QG_左载具顶升气缸回原点();
                    //ZK_左载具真空吸1真空关();
                    //ZK_左载具真空吸2真空关();
                    //ZK_左载具真空破1真空破();
                    //ZK_左载具真空破2真空破();
                    //产量
                    Tool.Count.AddOK1();


                    Tool.Count.AddCT1(CT.ToString());

                    AutoStep = 250;
                    break;
                case 250:
                    //WaitSysBit(SysBit.左下料发送至左相机取料完成信号, true);
                    //WriteSysBit(SysBit.左下料发送至左相机取料完成信号, false);
                    //WriteSysBit(SysBit.左下料发送至左相机取料完成信号, false);
                    AutoStep = 260;
                    break;
                case 260:
                    AbsMove("左直线X安全位");
                    WaitAbs("左直线X安全位");
                    AutoStep = 270;
                    break;
                case 270:
                    //WriteSysBit(SysBit.左相机发送至左下料安全信号, true);
                    AutoStep = 280;
                    break;
                case 280:
                    AutoStep = 0;
                    break;
            }
        }

        /// <summary>
        /// 等待左相机拍照完成信号
        /// </summary>

        public void WaitCamerL()
        {

        Line1:
            DateTime now = DateTime.Now;
            while (true)
            {
                bool a = GlobalVar.CamerL_Over;
                if (a == true)
                {
                    break;
                }
                else
                {
                    Thread.Sleep(10);
                    if ((DateTime.Now - now).Seconds > 15)//10秒
                    {
                        DialogResult result = MessageBox.Show("左相机完成信号", "超时提醒", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                        if (result == DialogResult.Abort)
                        {

                            //终止
                            Device.ChangeStateMode(Device.STATEMode.PAUSE);//切换暂停
                            break;
                        }
                        else if (result == DialogResult.Retry)
                        {
                            //重试
                            goto Line1;//重置超时
                        }
                        else if (result == DialogResult.Ignore)
                        {
                            //忽略
                            break;
                        }
                    }
                }
                Thread.Sleep(5);
            }
        }

        #region 气缸动作
        private void QG_上料气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("上料气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("上料气缸1原点", true);
        }
        private void QG_上料气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("上料气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("上料气缸2原点", true);
        }
        private void QG_出料气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("出料气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("出料气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("出料气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("出料气缸1原点", true);
        }
        private void QG_出料气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("出料气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("出料气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("出料气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("出料气缸2原点", true);
        }
        private void QG_夹爪气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("夹爪气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("夹爪气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("夹爪气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("夹爪气缸1原点", true);
        }
        private void QG_夹爪气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("夹爪气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("夹爪气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("夹爪气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("夹爪气缸2原点", true);
        }
        private void QG_夹爪升降气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("夹爪气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("夹爪气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("夹爪气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("夹爪气缸1原点", true);
        }
        private void QG_夹爪升降气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("夹爪升降气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("夹爪升降气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("夹爪升降气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("夹爪升降气缸2原点", true);
        }
        private void QG_进料气缸原点()
        {
            MotionMgr.GetInstance().WriteOut("进料气缸动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("进料气缸原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("进料气缸动点", false);
            MotionMgr.GetInstance().WaitIn("进料气缸原点", true);
        }
        private void QG_出料气缸原点()
        {
            MotionMgr.GetInstance().WriteOut("出料气缸动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("出料气缸原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("出料气缸动点", false);
            MotionMgr.GetInstance().WaitIn("出料气缸原点", true);
        }
        private void QG_平台搬运气缸原点()
        {
            MotionMgr.GetInstance().WriteOut("平台搬运气缸动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("平台搬运气缸原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("平台搬运气缸动点", false);
            MotionMgr.GetInstance().WaitIn("平台搬运气缸原点", true);
        }
        private void QG_取料定位气缸原点()
        {
            MotionMgr.GetInstance().WriteOut("取料定位气缸动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("取料定位气缸原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("取料定位气缸动点", false);
            MotionMgr.GetInstance().WaitIn("取料定位气缸原点", true);
        }
        private void QG_下料上下气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸1原点", true);
        }
        private void QG_下料上下气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸2原点", true);
        }
        private void QG_下料上下气缸3原点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸3动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸3原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸3动点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸3原点", true);
        }
        private void QG_下料上下气缸4原点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸4动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸4原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸4动点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸4原点", true);
        }
        private void QG_下料上下气缸5原点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸5动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸5原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸5动点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸5原点", true);
        }
        private void QG_磁吸升降气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸1原点", true);
        }
        private void QG_磁吸升降气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸2原点", true);
        }
        private void QG_磁吸升降气缸3原点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸3动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸3原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸3动点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸3原点", true);
        }
        private void QG_磁吸升降气缸4原点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸4动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸4原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸4动点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸4原点", true);
        }
        private void QG_磁吸升降气缸5原点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸5动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸5原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸5动点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸5原点", true);
        }
        private void QG_OK搬运升降气缸原点()
        {
            MotionMgr.GetInstance().WriteOut("OK搬运升降气缸动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("OK搬运升降气缸原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("OK搬运升降气缸动点", false);
            MotionMgr.GetInstance().WaitIn("OK搬运升降气缸原点", true);
        }
        private void QG_上料磁吸气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸1原点", true);
        }
        private void QG_上料磁吸气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸2原点", true);
        }
        private void QG_上料磁吸气缸3原点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸3动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸3原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸3动点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸3原点", true);
        }
        private void QG_上料磁吸气缸4原点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸4动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸4原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸4动点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸4原点", true);
        }
        private void QG_上料磁吸气缸5原点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸5动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸5原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸5动点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸5原点", true);
        }
        private void QG_入料口夹紧气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("入料口夹紧气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("入料口夹紧气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("入料口夹紧气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("入料口夹紧气缸1原点", true);
        }
        private void QG_入料口平移气缸原点()
        {
            MotionMgr.GetInstance().WriteOut("入料口平移气缸动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("入料口平移气缸原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("入料口平移气缸动点", false);
            MotionMgr.GetInstance().WaitIn("入料口平移气缸原点", true);
        }
        private void QG_入料口夹紧气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("入料口夹紧气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("入料口夹紧气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("入料口夹紧气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("入料口夹紧气缸2原点", true);
        }
        private void QG_入料口顶升气缸原点()
        {
            MotionMgr.GetInstance().WriteOut("入料口顶升气缸动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("入料口顶升气缸原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("入料口顶升气缸动点", false);
            MotionMgr.GetInstance().WaitIn("入料口顶升气缸原点", true);
        }
        private void QG_接料定位气缸1原点()
        {
            MotionMgr.GetInstance().WriteOut("接料定位气缸1动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("接料定位气缸1原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("接料定位气缸1动点", false);
            MotionMgr.GetInstance().WaitIn("接料定位气缸1原点", true);
        }
        private void QG_接料定位气缸2原点()
        {
            MotionMgr.GetInstance().WriteOut("接料定位气缸2动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("接料定位气缸2原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("接料定位气缸2动点", false);
            MotionMgr.GetInstance().WaitIn("接料定位气缸2原点", true);
        }
        private void QG_接料定位气缸3原点()
        {
            MotionMgr.GetInstance().WriteOut("接料定位气缸3动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("接料定位气缸3原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("接料定位气缸3动点", false);
            MotionMgr.GetInstance().WaitIn("接料定位气缸3原点", true);
        }
        private void QG_出料口气缸原点()
        {
            MotionMgr.GetInstance().WriteOut("出料口气缸动点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("出料口气缸原点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("出料口气缸动点", false);
            MotionMgr.GetInstance().WaitIn("出料口气缸原点", true);
        }


        private void QG_上料气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("上料气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("上料气缸1动点", true);
        }
        private void QG_上料气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("上料气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("上料气缸2动点", true);
        }
        private void QG_出料气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("出料气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("出料气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("出料气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("出料气缸1动点", true);
        }
        private void QG_出料气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("出料气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("出料气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("出料气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("出料气缸2动点", true);
        }
        private void QG_夹爪气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("夹爪气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("夹爪气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("夹爪气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("夹爪气缸1动点", true);
        }
        private void QG_夹爪气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("夹爪气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("夹爪气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("夹爪气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("夹爪气缸2动点", true);
        }
        private void QG_夹爪升降气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("夹爪气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("夹爪气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("夹爪气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("夹爪气缸1动点", true);
        }
        private void QG_夹爪升降气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("夹爪升降气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("夹爪升降气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("夹爪升降气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("夹爪升降气缸2动点", true);
        }
        private void QG_进料气缸动点()
        {
            MotionMgr.GetInstance().WriteOut("进料气缸原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("进料气缸动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("进料气缸原点", false);
            MotionMgr.GetInstance().WaitIn("进料气缸动点", true);
        }
        private void QG_出料气缸动点()
        {
            MotionMgr.GetInstance().WriteOut("出料气缸原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("出料气缸动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("出料气缸原点", false);
            MotionMgr.GetInstance().WaitIn("出料气缸动点", true);
        }
        private void QG_平台搬运气缸动点()
        {
            MotionMgr.GetInstance().WriteOut("平台搬运气缸原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("平台搬运气缸动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("平台搬运气缸原点", false);
            MotionMgr.GetInstance().WaitIn("平台搬运气缸动点", true);
        }
        private void QG_取料定位气缸动点()
        {
            MotionMgr.GetInstance().WriteOut("取料定位气缸原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("取料定位气缸动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("取料定位气缸原点", false);
            MotionMgr.GetInstance().WaitIn("取料定位气缸动点", true);
        }
        private void QG_下料上下气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸1动点", true);
        }
        private void QG_下料上下气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸2动点", true);
        }
        private void QG_下料上下气缸3动点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸3原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸3动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸3原点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸3动点", true);
        }
        private void QG_下料上下气缸4动点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸4原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸4动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸4原点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸4动点", true);
        }
        private void QG_下料上下气缸5动点()
        {
            MotionMgr.GetInstance().WriteOut("下料上下气缸5原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("下料上下气缸5动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("下料上下气缸5原点", false);
            MotionMgr.GetInstance().WaitIn("下料上下气缸5动点", true);
        }
        private void QG_磁吸升降气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸1动点", true);
        }
        private void QG_磁吸升降气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸2动点", true);
        }
        private void QG_磁吸升降气缸3动点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸3原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸3动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸3原点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸3动点", true);
        }
        private void QG_磁吸升降气缸4动点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸4原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸4动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸4原点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸4动点", true);
        }
        private void QG_磁吸升降气缸5动点()
        {
            MotionMgr.GetInstance().WriteOut("磁吸气缸5原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("磁吸气缸5动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("磁吸气缸5原点", false);
            MotionMgr.GetInstance().WaitIn("磁吸气缸5动点", true);
        }
        private void QG_OK搬运升降气缸动点()
        {
            MotionMgr.GetInstance().WriteOut("OK搬运升降气缸原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("OK搬运升降气缸动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("OK搬运升降气缸原点", false);
            MotionMgr.GetInstance().WaitIn("OK搬运升降气缸动点", true);
        }
        private void QG_上料磁吸气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸1动点", true);
        }
        private void QG_上料磁吸气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸2动点", true);
        }
        private void QG_上料磁吸气缸3动点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸3原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸3动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸3原点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸3动点", true);
        }
        private void QG_上料磁吸气缸4动点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸4原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸4动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸4原点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸4动点", true);
        }
        private void QG_上料磁吸气缸5动点()
        {
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸5原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("上料磁吸气缸5动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸5原点", false);
            MotionMgr.GetInstance().WaitIn("上料磁吸气缸5动点", true);
        }
        private void QG_入料口夹紧气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("入料口夹紧气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("入料口夹紧气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("入料口夹紧气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("入料口夹紧气缸1动点", true);
        }
        private void QG_入料口平移气缸动点()
        {
            MotionMgr.GetInstance().WriteOut("入料口平移气缸原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("入料口平移气缸动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("入料口平移气缸原点", false);
            MotionMgr.GetInstance().WaitIn("入料口平移气缸动点", true);
        }
        private void QG_入料口夹紧气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("入料口夹紧气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("入料口夹紧气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("入料口夹紧气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("入料口夹紧气缸2动点", true);
        }
        private void QG_入料口顶升气缸动点()
        {
            MotionMgr.GetInstance().WriteOut("入料口顶升气缸原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("入料口顶升气缸动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("入料口顶升气缸原点", false);
            MotionMgr.GetInstance().WaitIn("入料口顶升气缸动点", true);
        }
        private void QG_接料定位气缸1动点()
        {
            MotionMgr.GetInstance().WriteOut("接料定位气缸1原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("接料定位气缸1动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("接料定位气缸1原点", false);
            MotionMgr.GetInstance().WaitIn("接料定位气缸1动点", true);
        }
        private void QG_接料定位气缸2动点()
        {
            MotionMgr.GetInstance().WriteOut("接料定位气缸2原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("接料定位气缸2动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("接料定位气缸2原点", false);
            MotionMgr.GetInstance().WaitIn("接料定位气缸2动点", true);
        }
        private void QG_接料定位气缸3动点()
        {
            MotionMgr.GetInstance().WriteOut("接料定位气缸3原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("接料定位气缸3动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("接料定位气缸3原点", false);
            MotionMgr.GetInstance().WaitIn("接料定位气缸3动点", true);
        }
        private void QG_出料口气缸动点()
        {
            MotionMgr.GetInstance().WriteOut("出料口气缸原点电磁阀", false);
            MotionMgr.GetInstance().WriteOut("出料口气缸动点电磁阀", true);
            MotionMgr.GetInstance().WaitIn("出料口气缸原点", false);
            MotionMgr.GetInstance().WaitIn("出料口气缸动点", true);
        }
        #endregion

        #region 真空动作
        private void ZK_进料真空吸关()
        {
            MotionMgr.GetInstance().WriteOut("进料真空吸", false);
        }

        private void ZK_进料真空破关()
        {
            MotionMgr.GetInstance().WriteOut("进料真空破", false);
        }

        private void ZK_出料真空吸关()
        {
            MotionMgr.GetInstance().WriteOut("出料真空吸", false);
        }

        private void ZK_出料真空破关()
        {
            MotionMgr.GetInstance().WriteOut("出料真空破", false);
        }
        private void ZK_平台搬运真空吸关()
        {
            MotionMgr.GetInstance().WriteOut("平台搬运真空吸", false);
        }

        private void ZK_平台搬运真空破关()
        {
            MotionMgr.GetInstance().WriteOut("平台搬运真空破", false);
        }
        private void ZK_取料定位真空吸关()
        {
            MotionMgr.GetInstance().WriteOut("取料定位真空吸", false);
        }

        private void ZK_取料定位真空破关()
        {
            MotionMgr.GetInstance().WriteOut("取料定位真空破", false);
        }
        private void ZK_OK搬运真空吸关()
        {
            MotionMgr.GetInstance().WriteOut("OK搬运真空吸", false);
        }
        private void ZK_OK搬运真空破关()
        {
            MotionMgr.GetInstance().WriteOut("OK搬运真空破", false);
        }
        private void ZK_双工位1接料真空1吸关()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空1吸", false);
        }
        private void ZK_双工位1接料真空1破()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空1破", false);
        }
        private void ZK_双工位1接料真空2吸关()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空2吸", false);
        }
        private void ZK_双工位1接料真空2破()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空2破", false);
        }
        private void ZK_双工位1接料真空3吸关()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空3吸", false);
        }
        private void ZK_双工位1接料真空3破()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空3破", false);
        }
        private void ZK_双工位1接料真空4吸关()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空4吸", false);
        }
        private void ZK_双工位1接料真空4破关()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空4破", false);
        }
        private void ZK_双工位1接料真空5吸关()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空5吸", false);
        }
        private void ZK_双工位1接料真空5破关()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空5破", false);
        }
        private void ZK_出料口真空1吸关()
        {
            MotionMgr.GetInstance().WriteOut("出料口真空1吸", false);
        }
        private void ZK_出料口真空1破关()
        {
            MotionMgr.GetInstance().WriteOut("出料口真空1破", false);
        }
        private void ZK_出料口真空2吸关()
        {
            MotionMgr.GetInstance().WriteOut("出料口真空2吸", false);
        }
        private void ZK_出料口真空2破关()
        {
            MotionMgr.GetInstance().WriteOut("出料口真空2破", false);
        }


        private void ZK_进料真空吸开()
        {
            MotionMgr.GetInstance().WriteOut("进料真空吸", true);
        }

        private void ZK_进料真空破开()
        {
            MotionMgr.GetInstance().WriteOut("进料真空破", true);
        }

        private void ZK_出料真空吸开()
        {
            MotionMgr.GetInstance().WriteOut("出料真空吸", true);
        }

        private void ZK_出料真空破开()
        {
            MotionMgr.GetInstance().WriteOut("出料真空破", true);
        }
        private void ZK_平台搬运真空吸开()
        {
            MotionMgr.GetInstance().WriteOut("平台搬运真空吸", true);
        }

        private void ZK_平台搬运真空破开()
        {
            MotionMgr.GetInstance().WriteOut("平台搬运真空破", true);
        }
        private void ZK_取料定位真空吸开()
        {
            MotionMgr.GetInstance().WriteOut("取料定位真空吸", true);
        }

        private void ZK_取料定位真空破开()
        {
            MotionMgr.GetInstance().WriteOut("取料定位真空破", true);
        }
        private void ZK_OK搬运真空吸开()
        {
            MotionMgr.GetInstance().WriteOut("OK搬运真空吸", true);
        }
        private void ZK_OK搬运真空破开()
        {
            MotionMgr.GetInstance().WriteOut("OK搬运真空破", true);
        }
        private void ZK_双工位1接料真空1吸开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空1吸", true);
        }
        private void ZK_双工位1接料真空1开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空1破", true);
        }
        private void ZK_双工位1接料真空2吸开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空2吸", true);
        }
        private void ZK_双工位1接料真空2开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空2破", true);
        }
        private void ZK_双工位1接料真空3吸开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空3吸", true);
        }
        private void ZK_双工位1接料真空3开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空3破", true);
        }
        private void ZK_双工位1接料真空4吸开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空4吸", true);
        }
        private void ZK_双工位1接料真空4破开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空4破", true);
        }
        private void ZK_双工位1接料真空5吸开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空5吸", true);
        }
        private void ZK_双工位1接料真空5破开()
        {
            MotionMgr.GetInstance().WriteOut("双工位1接料真空5破", true);
        }
        private void ZK_出料口真空1吸开()
        {
            MotionMgr.GetInstance().WriteOut("出料口真空1吸", true);
        }
        private void ZK_出料口真空1破开()
        {
            MotionMgr.GetInstance().WriteOut("出料口真空1破", true);
        }
        private void ZK_出料口真空2吸开()
        {
            MotionMgr.GetInstance().WriteOut("出料口真空2吸", true);
        }
        private void ZK_出料口真空2破开()
        {
            MotionMgr.GetInstance().WriteOut("出料口真空2破", true);
        }

        #endregion
    }
}
